package czk.concrent.enjoyModelWithNotLock.unsafe;

import sun.misc.Unsafe;

import java.lang.reflect.Field;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/6/20 18:04
 */
public class UnsafeAccessor {
    private static Unsafe UNSAFE ;
    static {
        try {
            Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
            theUnsafe.setAccessible(true);
             UNSAFE = (Unsafe) theUnsafe.get(null);

        } catch (NoSuchFieldException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    public static Unsafe getUnsafe(){
        return UNSAFE;
    }
}
